# Set-PSDebug -Trace 1
$gopath = go env GOPATH

[Environment]::SetEnvironmentVariable("GOPATH", $gopath, "User")

$path = [Environment]::GetEnvironmentVariable("Path", "User")
if ($path -notlike "*$gopath\bin*") {
    [Environment]::SetEnvironmentVariable("Path", "$path;$gopath\bin", "User")
}

$env:GOPATH = $gopath
$env:Path += ";$gopath\bin"

Write-Host "GOPATH set to: $env:GOPATH"

if (-not (Get-Command "make" -ErrorAction SilentlyContinue)) {
    Write-Error "Error: 'make' command not found in PATH. Please install GNU Make and add it to your PATH."
    exit 1
}

Write-Host "`n[1/3] Running make presql..."
# & make presql

Write-Host "`n[2/3] Running make init..."
& make init

Write-Host "`n[3/3] Running make wire..."
& make wire